--天马恒途
local tianmahengtu = fk.CreateSkill {
    name = "mcdh_tianmahengtu",
    tags = {Skill.Compulsory}
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

tianmahengtu:addEffect(fk.CardUseFinished,{
    can_trigger = function(self, event, target, player, data)
        if target == player and player:hasSkill(self) then
            local tarid = TargetGroup:getRealTargets(data.tos)
            for _, id in ipairs(tarid) do
                if id == player.id then
                    return false
                end
            end
            local events = player.room.logic:getEventsOfScope(GameEvent.UseCard, 1, function(e)
                return e.data[1].from == player.id
            end, Player.HistoryTurn)
            return #events > 0 and events[1].data[1] == data
        end
    end,
    on_cost = function(self, event, target, player, data)
        return true
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local toPut = data.card:isVirtual() and data.card.subcards or { data.card.id }

        if #toPut > 1 then
            toPut = U.askForGuanxing(player, toPut, { #toPut, #toPut }, { 0, 0 }, self.name, nil, true).top
            toPut = table.reverse(toPut)
        end
        room:moveCardTo(toPut, Card.DrawPile, nil, fk.ReasonPut, self.name, nil, true)
    end,
})

tianmahengtu:addEffect('atkrange',{
    correct_func = function(self, from, to)
        if from:hasSkill(self.name) and from.hp < Fk:currentRoom():getBanner("RoundCount") then
            return 5
        end
        return 0
    end,
})

Fk:loadTranslationTable {
    ["mcdh_tianmahengtu"] = "天马恒途",
    [":mcdh_tianmahengtu"] = "锁定技。若当前游戏轮数大于你的体力值，你的攻击范围视为5。当你使用的牌结算结束后，若此牌为你本回合使用的第一张牌且目标不包含你自己，将此牌置于牌堆顶。",
}

return tianmahengtu